
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;

namespace Swaf.Script
{
	/// <summary>
	/// Thrown when an exception occurs in ActiveX scripting script code, 
	/// and maintains information about the specific script error.</summary>
	[Serializable]
	public class ScriptException : BaseException
	{
		public ScriptException(string msg, string context, int lineNum, int linePos)
			:base(String.Format("ScriptError:{0} in context '{1}' at line {2} pos {3}", msg, context, lineNum, linePos))
		{
			m_msg = msg;
			m_context = context;
			m_lineNum = lineNum;
			m_linePos = linePos;
		}
		
		public ScriptException(string msg, string context, int lineNum, int linePos, Exception innerException)
			:base(String.Format("ScriptError:{0} in context '{1}' at line {2} pos {3}, innerException {4}", msg, context, lineNum, linePos, innerException.ToString()), innerException)
		{
			m_msg = msg;
			m_context = context;
			m_lineNum = lineNum;
			m_linePos = linePos;
		}

		public ScriptException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
		{
		}

		public string ScriptError{get{return m_msg;}}
		protected string m_msg;

		public string Context{get{return m_context;}}
		protected string m_context;

		public int LineNum{get{return m_lineNum;}}
		protected int m_lineNum;

		public int LinePos{get{return m_linePos;}}
		protected int m_linePos;
	}
}
